{template 'common/header'}
<script>
    $(function(){
        $(".add").click(function(){
            var day = $("#day").val();
            var type_id = $("#type_id").val();
            var se_man = $("#se_man").val();
            var price = $("#price").val();
            var remark = $("#remark").val();
            var content = $("#content").val();
            if(day != '' && type_id > 0 && se_man != '' && price > 0){
                var url = "{php echo $this->createWebUrl('pay',array('op' => 'add'))}";
                $.ajax({
                    type : 'post',
                    url : url,
                    data : {'day' : day, 'type_id' : type_id, 'se_man' : se_man, 'price' : price, 'remark' : remark, 'content' : content},
                    success : function(data){
                        if(data == 111){
                            location.href="{php echo $this->createWebUrl('pay')}";
                        }else{
                            alert(data);
                        }
                    }
                });
            }else{
                alert("请输入相关的内容");
            }

        });
        $(".find").click(function(){
            var day = $("#day").val();
            var type_id = $("#type_id").val();
            var se_man = $("#se_man").val();
            var price = $("#price").val();
            var remark = $("#remark").val();
            var content = $("#content").val();
            location.href="{php echo $this->createWebUrl('pay')}&day="+day+"&type_id="+type_id+"&se_man="+se_man+"&price="+price+"&remark="+remark+"&content="+content;
        });
        $(".export-data").click(function(){
            var day = $("#day").val();
            var type_id = $("#type_id").val();
            var se_man = $("#se_man").val();
            var price = $("#price").val();
            var remark = $("#remark").val();
            var content = $("#content").val();
            location.href="{php echo $this->createWebUrl('pay',array('op' => 'export'))}&day="+day+"&type_id="+type_id+"&se_man="+se_man+"&price="+price+"&remark="+remark+"&content="+content;
        });
        $(".se-man").change(function(){
            var name = $(this).val();
            $("#se_man").val(name);
        });
    });

</script>
<ul class="nav nav-tabs">
    <li ><a href="{php echo $this->createWebUrl('pay', array('op'=>'index'))}">支出记录</a></li>
    <li class="active" ><a href="{php echo $this->createWebUrl('pay', array('op'=>'to_add'))}">新增记录</a></li>
    <li  ><a href="{php echo $this->createWebUrl('pay', array('op'=>'type'))}">财务类型</a></li>
</ul>
<div class="main">
    <div class="row" >
        <div class="col-xs-3">
            <input type="date" class="form-control" {if $day} value="{$day}"{/if} id="day" />
        </div>
        <div class="col-xs-3">
            <select class="form-control" id="type_id">
                <option value="0">请选择支出类型</option>
                {loop $types $type}
                <option value="{$type['id']}" {if $type_id == $type['id']} selected="selected"{/if}>{$type['name']}</option>
                {/loop}
            </select>
        </div>
        <div class="col-xs-3">
            <input type="text" class="form-control" placeholder="请输入金额" id="price" value="{$price}" />
        </div>
        <div class="col-xs-3">
            <input type="text" class="form-control" placeholder="请输入支出明细" id="remark" value="{$remark}" />
        </div>
    </div>
    <br />
    <div class="row">
        <div class="col-xs-3">
            <input type="text" class="form-control" placeholder="结算人" id="se_man" value="{$se_man}" />
        </div>
        <div class="col-xs-3">
            <select class="form-control se-man">
                <option value="">历史结算人</option>
                {loop $se_mans $se_man}
                <option value="{$se_man['name']}">{$se_man['name']}</option>
                {/loop}
            </select>
        </div>


        <div class="col-xs-3">
            <input type="text" class="form-control" placeholder="备注" id="content" value="{$content}" />
        </div>

    </div>
    <br />
    <div class="row">
        <div class="col-xs-3">
            <button class="btn btn-default add">添加</button>
        </div>
    </div>
    <br />
    <div>
    </div>
</div>



{template 'common/footer'}